#include <inttypes.h>
#include <avr/io.h>
#include "serial.h"

void set_pin_HIGH() {
	// set the bit high, start flashing a new program
	PROGPORT |= PROGPIN;
}

void set_pin_LOW() {
	// set the bit low, start executing the program
	PROGPORT &= ~PROGCTRL;
}

void sendCommand(uint8_t c) {
	uart_putc(c);
}

/** rxCheck() checks to see if a serial character has been received
 * Returns Character to receive or else 0
 */
char rxCheck(void) {
	return UCSR1A & _BV(RXC1);
}

/**waits for a character to be received and returns it
 * returns The received character
 */
unsigned char recCommand(void) {
	while (!(UCSR1A & _BV(RXC1)))
		;

	return UDR1;
}
